<template>
	<navbar title="我的课程" :isBack="true"></navbar>

	<view class="page" v-if="list.length >0">
		<item :list="list"></item>
	</view>
	<view  v-else>
		<nodata></nodata>
	</view>
</template>

<script setup lang="ts">
	import { ref, reactive } from 'vue'
	import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
		import { orderList } from '@/service/api/index'
	import item from './item.vue'
	import nodata from '@/components/nodata.vue'
	const list = ref<Array<orderListType>>([
	])
	const Info = reactive({
		current_page: "",
		last_page: "",
		total: ""
	})
	const param = reactive({
		page: 1
	})
	onShow(() => {
		list.value = [];
		getData()
	})

	onReachBottom(() => {
		if (Info.last_page > Info.current_page) {
			param.page += 1;
			getData()
 
		}

	})
	const getData = async () => {
		
		const res = await orderList(param);
		list.value = list.value.concat(res.msg.data);
		for (let i in Info) {
			Info[i] = res.msg[i]
		}
		console.log(list.value);
	}

	//时间戳转时分秒
	//倒计时
	// const countTimer = ()=>{
	// 	list.value.forEach((item:any)=>{
	// 	let time =	setInterval(()=>{
	// 			item.timer-=1;

	// / 			/ / countDate(item.timer)
		// 			if(item.timer <= 0){
		// 				clearInterval(time)
		// 				item.state = '4';
		// 			}
		// 		},1000)

		// /})
	// }
	// const getData = ()=>{
	// 	// countTimer()
	// 	//
	// }
	// getData()
</script>

<style scoped lang="scss">
	.page {
		min-height: calc(100vh - 68px);
		background-color: #F8F8F9;
		padding: 20rpx 30rpx 30rpx 20rpx;
		overflow: hidden;
	}
</style>